<?php
function dok_add($DOK_ID, $DETPERB_NO, $DOK_NAMA, $DOK_TYPE, $DOK_SIZE, $DOK_CONTENT, $DOK_IMG_WIDTH, $DOK_IMG_HEIGHT){
	$sql = "INSERT INTO dokumen VALUES ('', '$DETPERB_NO', '$DOK_NAMA', '$DOK_TYPE', '$DOK_SIZE', '$DOK_CONTENT', '$DOK_IMG_WIDTH', '$DOK_IMG_HEIGHT')";
	return mysql_query($sql);
}

function dok_delete($DOK_ID=false, $DETPERB_NO=false){
	$sql = "DELETE FROM dokumen " . ($DOK_ID || $DETPERB_NO? " WHERE " : "");
	$sql .= $DOK_ID? " DOK_ID='$DOK_ID' " : "";
	$sql .= ($DOK_ID? " AND " : "") ." DETPERB_NO='$DETPERB_NO' ";
	return mysql_query($sql);
}

function dok_load($DOK_ID=false, $DETPERB_NO=false, $startOffset=0, $length=1){
	$sql = "SELECT * FROM dokumen ";
	if ($DOK_ID || $DETPERB_NO || $startOffset || $length) $sql .= " WHERE ";
	if ($DOK_ID){
		$sql .= " DOK_ID='$DOK_ID' ";
	}
	if ($DETPERB_NO){
		$sql .= ($DOK_ID? " AND " : ""); 
		$sql .= " DETPERB_NO='$DETPERB_NO' ";
	}
	$sql .= $startOffset? " LIMIT $startOffset,$length" : "";
	return mysql_query($sql);
}